// 卡片模型

// 定义卡片基本属性


class ExchangeCard {
  final int id;
  final String name;
  final String? imageUrl;
  final int exchangeRequestCount; // 交换请求数量
  final DateTime? expiryTime; // 有效期
  final bool owned; // 是否拥有

  ExchangeCard({
    required this.id,
    required this.name,
    this.imageUrl,
    this.exchangeRequestCount = 0,
    this.expiryTime,
    this.owned = false,
  });

  factory ExchangeCard.fromJson(Map<String, dynamic> json) {
    return ExchangeCard(
      id: json['id'] as int,
      name: json['name'] as String,
      imageUrl: json['imageUrl'] as String,
      exchangeRequestCount: json['exchangeRequestCount'] as int? ?? 0,
      expiryTime: json['expiryTime'] != null 
          ? DateTime.parse(json['expiryTime'] as String)
          : null,
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'name': name,
      'imageUrl': imageUrl,
      'exchangeRequestCount': exchangeRequestCount,
      'expiryTime': expiryTime?.toIso8601String(),
    };
  }
} 